package com.fengye.school.model;

import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

/**
 * 模型的基类,所有的数据库模型都继承这个类
 */
@MappedSuperclass
@EntityListeners(value = AuditingEntityListener.class)
@Data
public abstract class BaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(columnDefinition = "bigint comment 'id,主键自增长'")
    private long id;

    @CreatedDate
    @Column(insertable = true, updatable = false, columnDefinition = "datetime(6) comment '创建时间'")
    private Date createTime;

    @LastModifiedDate
    @Column(insertable = true, updatable = true, columnDefinition = "datetime(6) comment '更新时间'")
    private Date updateTime;
}